Skip to content

Fix dead code in content_block_stop handler and hardcoded provider names#1149

Closed
cursor[bot] wants to merge 1 commit intocodething/648ca884-claudefrom
cursor/provider-stream-and-kind-03d6
Closed

Fix dead code in content_block_stop handler and hardcoded provider names#1149
cursor[bot] wants to merge 1 commit intocodething/648ca884-claudefrom
cursor/provider-stream-and-kind-03d6

Conversation

@cursor
Copy link
Contributor

@cursor cursor bot commented Mar 16, 2026

What Changed

Two small code quality fixes in the server package:

  1. ClaudeAdapter.ts: Removed dead code in the content_block_stop stream event handler. The handler looked up an in-flight tool via context.inFlightTools.get(index) but did nothing with the result — the early return guard for missing tools and the fall-through for found tools both ended execution with no action.

  2. ProviderCommandReactor.ts: Replaced hardcoded === "codex" || === "claudeAgent" string comparison with Schema.is(ProviderKind) for type-safe provider validation. The previous approach would silently produce undefined if a new provider were added to the ProviderKind union without updating this check, causing unnecessary session restarts.

Why

  • The dead tool lookup in bug 1 was confusing and suggested missing logic. Since tools are completed elsewhere (via handleUserMessage and completeTurn), the lookup was unnecessary.
  • The hardcoded provider list in bug 2 bypassed type-safe exhaustiveness checking. Using the schema-based guard ensures any new providers added to ProviderKind are automatically recognized.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes — N/A (no UI changes)
  • I included a video for animation/interaction changes — N/A
Open in Web Open in Cursor 

Note

Fix hardcoded provider name checks and dead code in content_block_stop handler

  • Replaces hardcoded "codex" / "claudeAgent" string checks in ProviderCommandReactor.ts with a Schema.is(ProviderKind) guard, so any valid ProviderKind value resolves currentProvider correctly.
  • Removes a dead early-return branch in ClaudeAdapter.ts that fetched from inFlightTools when a content_block_stop event had no matching assistant block.
  • Behavioral Change: currentProvider now matches any conforming ProviderKind value rather than only the two previously hardcoded names.

Macroscope summarized fab42af.

- Remove dead tool lookup in ClaudeAdapter's content_block_stop handler
  that retrieved an in-flight tool but never used it
- Replace hardcoded provider name comparison with Schema.is(ProviderKind)
  in ProviderCommandReactor for type-safe exhaustiveness checking

Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions bot added size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants